package com.zzy.pool.pool2.mypool;

import java.io.IOException;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.junit.Test;

import com.zzy.pool.pool2.poolobj.StringFactory;

public class TestMain {

	@Test
	public void testMa() {

		GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
		poolConfig.setMaxTotal(10);
		StringFactory factory = new StringFactory();
		StringPool pool = new StringPool(poolConfig, factory);
		for (int i = 0; i < 15; i++) {
			System.out.println(i + ":");
			String str = pool.getResource();
			
			System.out.println(str);
			
			pool.returnResourceObject(str);
		}
		try {
			pool.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
